<?php namespace App\Http\Services;

use App\DistributionWithdraw;
use App\Orders;
use DB;

class DistributionManager
{
//    public static function distributionSettleAccount(Orders $orders){
//        if($orders->status != 4)
//            return false;
//
//        //开始佣金结算
//        try{
//            DB::beginTransaction();
//            $newDistributionWithdraws = new DistributionWithdraw();
//            $newDistributionWithdraws->user_id = $user->id;
//            $newDistributionWithdraws->img_id  = $userInfo ? $userInfo->photo_id : 0;
//            $newDistributionWithdraws->name    = $realname;
//            $newDistributionWithdraws->phone   = $phone;
//            $newDistributionWithdraws->withdraws_amount = $amount;
//            $newDistributionWithdraws->withdraws_way = "wechat";
//            $newDistributionWithdraws->withdrawal_num = "t".ToolsManager::makeBillNum();
//            $newDistributionWithdraws->submit_time = date("Y-m-d H:i:s",time());
//            $newDistributionWithdraws->save();
//
//            $userCommissions->available_money = $userCommissions->available_money - $amount;
//            $userCommissions->save();
//            DB::commit();
//        }catch (Exception $e){
//            DB::rollBack();
//            \Log::error($e->getTraceAsString());
//            return response()->json(['level'=>'error','message'=>'提现错误，错误信息：'.$e->getMessage()]);
//        }
//    }
//
//    private function doNextSettleAccount(){
//
//    }
}
